package com.lishe.lishe.lishe.module.myorder.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lishe.lishe.R;
import com.lishe.lishe.lishe.module.myorder.bean.CourierObject;

import java.util.List;

/**
 * Created by shino on 2017/12/1.
 */

public class CourierAdapter extends RecyclerView.Adapter<CourierAdapter.myViewHolder> {

    List<CourierObject> objects;

    public CourierAdapter(List<CourierObject> objects) {
        this.objects = objects;
    }

    @Override
    public myViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_time_path, null);

        return new myViewHolder(view);
    }

    @Override
    public void onBindViewHolder(myViewHolder holder, int position) {
        CourierObject courierObject = objects.get(position);
        holder.text.setText(courierObject.getNote());
        holder.time.setText(courierObject.getTime());
    }

    @Override
    public int getItemCount() {
        return objects == null ? 0 : objects.size();
    }

    class myViewHolder extends RecyclerView.ViewHolder {
        TextView text;
        TextView time;

        public myViewHolder(View itemView) {
            super(itemView);
            text = itemView.findViewById(R.id.text);
            time = itemView.findViewById(R.id.time);
        }
    }
}
